<?php
  $rs=$this->rs;
?>
<style type="text/css" title="currentStyle">
	@import "/js/DataTables/css/demo_page.css";
	@import "/js/DataTables/css/demo_table_jui.css";
	@import "/js/TableTools/media/css/TableTools.css";
	@import "/js/TableTools/media/css/TableTools_JUI.css";
</style>

<?php require_once("imports.php"); ?>
<script src="/js/jquery.dataTables.js" language="Javascript"></script>
<script src="/js/dataTables.currency.js" language="Javascript"></script>
<script src="/js/dataTables.date.js" language="Javascript"></script>
<script src="/js/dataTables.folio.js" language="Javascript"></script>
<script src="/js/TableTools/media/js/ZeroClipboard.js" language="Javascript"></script>
<script src="/js/TableTools/media/js/TableTools.js" language="Javascript"></script>

<script language="JavaScript">
	$(document).ready(function(){
		$('#OTs').dataTable( {
			"sDom": '<"tablebuttons"T><"clear"><"H"lr>t<"F"ip>',
			"oTableTools": {
				"aButtons": [
					{
						"sExtends": "print",
						"sButtonText": "Imprimir"
					}
				]
			},
			"aoColumns" : [
				{"sType": "folio"},
				null,
				{"sType": "currency"},
				null,
				null,
				null,
				null
			],
			"bJQueryUI": true,
			"sPaginationType": "full_numbers",
			"oLanguage": {
				"sFirst": "Primera",
				"sLengthMenu": "Mostrar _MENU_ registros a la vez",
				"sSearch": "Filtro:",
				"sZeroRecords": "No se encontraron registros de acuerdo al criterio",
				"sInfo": "Mostrando _START_ a _END_ de _TOTAL_ registros",
				"sInfoFiltered": "(filtrados de un total de _MAX_ registros)",
				"oPaginate": {
					"sFirst":    "Primera",
					"sPrevious": "<-",
					"sNext":     "->",
					"sLast":     "Última"
				}
			}
		} );
});		
</script>
<table align='center' width='100%' border=0><tr><td bgcolor='#FF0000'><font color='#FFFFFF'><b><center>Todas las OTs</center></b></font></td></tr></table><p>

  <?php
  if ($rs!=null):
    print "<table width=100% cellpadding='0' cellspacing='0' border='0' id='OTs' class='display' style='/*display:none;*/'>";
    print "<thead><tr><th>No. de folio</th><th>Número MAG</th><th>Valor de la cotización</th><th>Aprobada</th><th>Estatus</th><th>Commentarios</th><th>".($_GET["op"]!="update" ? "Ver detalle" : "Modificar")."</th></tr></thead>";
    print "<tbody>";
    while($row=$rs->fetch())
    {
      print "<tr class='gradeX'><td>".str_pad($row['mag_folio'],4,"0",STR_PAD_LEFT)."/".$row["mag_year"]."</td><td>".$row["mag_cliente"]."-".$row["mag_numero"]."</td><td>$".number_format($row["mag_costo"],2)."</td><td>".($row["approved"]==1 ? "Sí" : "No")."</td><td>".($row["open"]==1 ? "Abierta" : "Cerrada")."</td><td><input type='button' value='Leer comentarios' id='comments' onclick='javascript:OTcomment(\"".$row["mag_id"]."\");' /></td><td><input type='button' ".($_GET["op"]!="update" ? "value='Ver detalle' onclick='javascript:detail(&quot;".$row["mag_id"]."&quot;);'" : "value='Modificar' onclick='javascript:upd(&quot;".$row["mag_id"]."&quot;);'")." /></td></tr>";
      }
    print "</tbody>
        <tfoot id='filters'>
          <tr>
            <th><input type='text' class='search_init' id='folios' value='Filtrar folios' size='10' /></th>
            <th><input type='text' class='search_init' id='MAG' value='Filtrar números MAG' size='10' /></th>
            <th><input type='text' class='search_init' id='val' value='Filtrar valor'  size='10' /></th>
            <th><input type='text' class='search_init' id='approv' value='".($_GET["approv"] == 1 ? "No" : "Filtrar aprobación")."' size='10' /></th>
            <th><input type='text' class='search_init' id='estatus' value='".($_GET["open"] == 1 ? "Cerrada" : ($_GET["open"] == 2 ? "Abierta" : "Filtrar estatus"))."' size='10' /></th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
          </tr>
        </tfoot>
    </table>
    <input class='smallbutton' type='button' onclick='javascript:fnPrint([5,6],\"OTs\");' value='Imprimir' /><p>
    <p>
    <input type='hidden' name='rtype' value='' />
    <input type='hidden' name='searchr' value='6' />
    <input type='hidden' name='optype' value='s' />
    <input type='hidden' name='mag_id' value='' />
    ";
  else:
  ?>
    <center><b>No hay resultados</b></center>
    <?php
  endif;
  ?>